home *** CD-ROM | disk | FTP | other *** search
- 'STUDENT.QB4 - Illustrates the use of the TYPE/END TYPE statements and
- 'how they can make your life so much easier and uncomplicated!
-
- 'From the GWBT10 (GW-BASIC Tutorial Series #10) 04/01/1991
- 'Program written by Richard G. Harper
-
- TYPE StudentRecord 'This replaces the FIELD #1,
- StudName AS STRING * 18 '18 AS STUDNAME$,
- StudID AS DOUBLE '8 AS STUDID$,
- StudCC AS INTEGER '2 AS STUDCC$,
- StudGPA AS SINGLE '4 AS STUDGPA$
- END TYPE
-
- DIM SRecord AS StudentRecord 'Now we can just call the whole mess
- 'a SRecord...
-
- OPEN "STUDENT.DAT" FOR RANDOM AS #1 LEN = 32
-
- Start:
- COLOR 6, 0, 0
- CLS
- PRINT "Press 'R' to read in a student's information from disk, 'W' to"
- PRINT "enter and write a student's information to disk, or 'Q' to quit..."
- GetKey:
- AA$ = INKEY$
- IF AA$ = "Q" OR AA$ = "q" THEN
- CLOSE
- RESET
- END
- ELSEIF AA$ = "R" OR AA$ = "r" THEN
- GOTO ReadRecord
- ELSEIF AA$ = "W" OR AA$ = "w" THEN
- GOTO WriteRecord
- ELSE
- GOTO GetKey
- END IF
-
- ReadRecord:
- CLS
- PRINT "To find a student's information on disk, I need you to give me the"
- PRINT "Student ID code. Please enter it below..."
- PRINT
- INPUT "Student ID: "; StudentID#
- PRINT
- PRINT "Looking, please wait..."
- EN1 = LOF(1) / 32
- FOR Record = 1 TO EN1
- GET #1, Record, SRecord
- IF StudentID# = SRecord.StudID THEN
- PRINT "Information is as follows:"
- PRINT "Student Last Name: "; SRecord.StudName
- PRINT "Student ID Code : "; SRecord.StudID
- PRINT "Course Code : "; SRecord.StudCC
- PRINT "Student GPA : "; SRecord.StudGPA
- END IF
- NEXT Record
- PRINT "Search complete. Press any key to continue..."
- WHILE INKEY$ = "": WEND
- GOTO Start
-
- WriteRecord:
- CLS
- PRINT "Please provide the requested information below..."
- PRINT
- LINE INPUT "Student Last Name: "; SRecord.StudName
- INPUT "Student ID Code : "; SRecord.StudID
- INPUT "Course Code : "; SRecord.StudCC
- INPUT "Student GPA : "; SRecord.StudGPA
- PRINT
- PRINT "If all of the above are correct, press 'Y' to save to disk, or else"
- PRINT "press 'N' to re-enter the information..."
- GetWriteKey:
- AA$ = INKEY$
- IF AA$ = "Y" OR AA$ = "y" THEN
- EN1 = LOF(1) / 32
- EN1 = EN1 + 1
- PUT #1, EN1, SRecord
- GOTO Start
- ELSEIF AA$ = "N" OR AA$ = "n" THEN
- GOTO WriteRecord
- ELSE
- GOTO GetWriteKey
- END IF
-
- 'End of program - STUDENT.QB4
-
-